package com.linwen.excise.leetcode;

/**
 * @ClassName _1281整数的各位积和之差
 * @Description TODO
 * @Author zero
 * @DATE 2024/9/22 2:16 AM
 * @Version 1.0
 */
public class _1281整数的各位积和之差 {
    public static void main(String[] args) {
        _1281整数的各位积和之差 inst = new _1281整数的各位积和之差();
        System.out.println(inst.subtractProductAndSum(234));
    }
    public int subtractProductAndSum(int n) {
        int sum = 0;
        int multi = 1;
        while (n > 0) {
            int temp = n % 10;
            sum += temp;
            multi *= temp;
            n /= 10;
        }
        return multi - sum;
    }
}
